<template>

  <!--
    作者：luoyiming
    时间：2020-06-04
    描述：插件中心-直播-直播房间列表-修改
  -->
  <el-dialog title="修改" v-model="dialogVisible" @close="dialogFormVisible" :close-on-click-modal="false" :close-on-press-escape="false" width="500px">
    <el-form size="small" :model="form"  ref="form">
      <el-form-item label="是否顯示" prop="is_delete" :label-width="formLabelWidth">
        <el-radio v-model="form.isDelete" :label="0">顯示</el-radio>
        <el-radio v-model="form.isDelete" :label="1">隱藏</el-radio>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible">取 消</el-button>
        <el-button type="primary" @click="confirmFunc" :loading="loading">確 定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
import liveApi from '@/api/live.js';
export default {
  components: {},
  data() {
    var audit_status = (rule, value, callback) => {
      if (value === '' || value === 0) {
        callback(new Error("請選擇狀態"));
      } else {
        callback();
      }
    };
    return {
      /*左边长度*/
      formLabelWidth: '120px',
      /*是否显示*/
      dialogVisible: false,
      loading: false
    };
  },
  props: ['open', 'form'],
  watch: {
    open: function (n, o) {
      if (n != o) {
        this.dialogVisible = n;
      }
    }
  },
  created() {},
  methods: {
    /*审核*/
    confirmFunc() {
      let self = this;
      let param = self.form;
      self.$refs.form.validate(valid => {
        if (valid) {
          self.loading = true;
          liveApi.editRoom(param, true).then(res => {
            self.loading = false;
            ElMessage({
              message: "修改成功",
              type: 'success'
            });
            self.dialogFormVisible(true);
          }).catch(error => {
            self.loading = false;
          });
        }
      });
    },
    /*关闭弹窗*/
    dialogFormVisible(e) {
      if (e) {
        this.$emit('close', true);
      } else {
        this.$emit('close', null);
      }
    }
  }
};
</script>

<style scoped>
.img {
  margin-top: 10px;
}
</style>

